At present, a layer 2 network uses the virtual local area network (Virtual Local Area Network, VLAN) technology. A layer 2 network includes many access devices. Each access device is connected to many users, and the users are distributed into a plurality of VLANs.
In the layer 2 network, an Ethernet packet is forwarded based on VLAN information and Media Access Control (Media Access Control, MAC) address information. Therefore, each access device needs to know the VLAN or VLANs to which each port of the device is connected and the MAC address of another device to which the port is connected. For configuration of the VLAN information for each port of an access device, the manual configuration manner is used at present.
For a large-size layer 2 network, because the network topology is complicated, the configuration of the VLAN information is of high complexity. If the manual configuration method is used, the risk of a configuration error is high, which may lead to service faults in the layer 2 network. Moreover, because the network topology often changes and the VLAN information to be configured often changes accordingly and therefore requires reconfiguration by an operator each time it changes, manual configuration is of poor feasibility in an actual application. When the Spanning Tree Protocol (Spanning Tree Protocol, STP) is used for a layer 2 network, the network topology is changed through an STP algorithm, but the physical connection between each two access devices in the layer 2 network does not change. Then the operator cannot know the topology change while it takes place and therefore cannot perform reconfiguration. In a word, the existing method of manual configuration of the VLAN information for an access device is of low accuracy and poor feasibility.